CC          = @CC@
AR          = @AR@
LIBNAME     = @LIBNAME@
srcdir      = @srcdir@
CC_SHL      = @CC_SHL@
SHLIBNAME   = @SHLIBNAME@

INCLUDES = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include -I../../include  -I${srcdir}/../../../../include -I../../../../include @CPPFLAGS@
CFLAGS      = @CFLAGS@ $(INCLUDES) -DBGL_OPTIM_STEP1_2=1 -DBGL_OPTIM_STEP1_1=1

C_COMPILE_SHL = $(CC_SHL) @CFLAGS@ $(INCLUDES)

@VPATH@

AD_BGL_OBJECTS = \
      ad_bgl_open.o ad_bgl_close.o \
      ad_bgl_fcntl.o ad_bgl_flush.o \
      ad_bgl_read.o ad_bgl_write.o ad_bgl_getsh.o ad_bgl_setsh.o \
      ad_bgl.o ad_bgl_aggrs.o ad_bgl_pset.o ad_bgl_hints.o \
      ad_bgl_rdcoll.o ad_bgl_wrcoll.o ad_bgl_tuning.o

default: $(LIBNAME)
	@if [ "@ENABLE_SHLIB@" != "none" ] ; then \
	    $(MAKE) $(SHLIBNAME).la ;\
	fi

.SUFFIXES: $(SUFFIXES) .p .lo

.c.o:
	$(CC) $(CFLAGS) -c $<
.c.lo:
	$(C_COMPILE_SHL) $(CFLAGS) -c $<
	@mv -f $*.o $*.lo

$(LIBNAME): $(AD_BGL_OBJECTS)
	$(AR) $(LIBNAME) $(AD_BGL_OBJECTS)

AD_BGL_LOOBJECTS=$(AD_BGL_OBJECTS:.o=.lo)
$(SHLIBNAME).la: $(AD_BGL_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(AD_BGL_LOOBJECTS)

coverage:
	-@for file in  ${AD_BGL_OBJECTS:.o=.c} ; do \
		gcov -b -f $$file ; done

clean:
	@rm -f *.o *.lo
